﻿using System;

namespace SLS.ExClassLib.MultiThreading.Extensions
{
    public static class ExceptionExtensions
    {
        /// <summary>
        /// Create text with exception type and exception message
        /// </summary>
        /// <param name="exception">Exception</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"/>
        /// <example>Type: FileNotFoundException Message: C:\file.txt</example>
        public static string ToShortString(this Exception exception)
        {
            if (exception.IsNull())
                throw new ArgumentNullException("exception", "exception is null");
            return string.Format("Type: {0}, Message: {1}", exception.GetType().Name, exception.Message);
        }
    }
}